<?php
/* @var $this CategoryController */
/* @var $model Category */
/* @var $form CActiveForm */
?>
<?php $form=$this->beginWidget('CActiveForm', array(
    'id'=>'category-form',
    // Please note: When you enable ajax validation, make sure the corresponding
    // controller action is handling ajax validation correctly.
    // There is a call to performAjaxValidation() commented in generated controller code.
    // See class documentation of CActiveForm for details on this.
    'htmlOptions'=>array('class'=>'form-horizontal', 'enctype'=>'multipart/form-data'),
    'enableAjaxValidation'=>false,
)); ?>

    <?php echo $form->errorSummary($model); ?>
    <div class="form-group">
        <label class="col-sm-2 control-label">父类名称</label>
        <div class="col-sm-10">
            <?php //var_dump( array_merge( array('0'=>'请选择'),Category::getCategoriesName() ) )?>
            <select class="chosen-select form-control" name="Category[parent_id]" id="Category_parent_id">
                <option value="0">请选择</option>
<?php foreach ( Category::getCategoryTree( 0 ,Category::getCategories()) as $category) {?>
                <option value="<?=$category['id']?>"<?php if($category['id']==$model->parent_id){echo' selected';}?>> <?=$category['str_repeat']?>├ <?=$category['name']?></option>
<?php }?>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">分类模型</label>
        <div class="col-sm-10">
            <?php echo $form->dropDownList($model,'type',Constants::getCategoryTypeItems(), array('class'=>'form-control')); ?>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">名称</label>
        <div class="col-sm-10">
            <?php echo $form->textField($model,'name',array('size'=>11,'maxlength'=>11,'class'=>'form-control')); ?>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label">别名</label>
        <div class="col-sm-10">
            <?php echo $form ->textField( $model , 'alias', array('class'=>'form-control'));?>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">排序</label>
        <div class="col-sm-10">
            <?php echo $form->textField($model,'sort',array('size'=>60,'maxlength'=>255,'class'=>'form-control')); ?>
        </div>
    </div>
    <div class="form-group">
        <?php echo $form->labelEx($model,'thumb',array('class'=>'col-sm-2 control-label')); ?>
        <div class="col-sm-10 image">
            <input id="ytCategory_thumb" type="hidden" value="" name="Category[thumb]"><input class="form-control pretty-file img-responsive" name="Category[thumb]" id="Category_thumb" type="file" value="<?php echo $model->thumb?>">
            <?php //echo $form->fileField($model,'thumb',array('class'=>'form-control pretty-file img-responsive')); ?>

            <div style='position:relative'>
                <img class="pretty-file img-responsive" src="<?php echo $model->thumb;?>" alt="" style="max-width:100px;max-height:100px" text="选择图片" nonePicUrl="<?=Yii::app()->baseUrl;?>/resource/backend/images/none.jpg">
<?php if(!$model->isNewRecord){?>
                    <div onclick="$(this).parents('.image').find('input[type=hidden]').val(0);$(this).prev().attr('src', '<?=Yii::app()->baseUrl;?>/resource/backend/images/none.jpg');$(this).remove()" style='position:absolute;width:50px;padding:5px 3px 3px 5px;top:5px;left:6px;background:black;opacity:0.6;color:white;cursor:pointer'>
                        <i class='fa fa-trash' aria-hidden='true'> 删除</i>
                    </div>
<?php }?>
            </div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">关键词</label>
        <div class="col-sm-10">
            <?php echo $form->textField($model,'keywords',array('size'=>60,'maxlength'=>255,'class'=>'form-control')); ?>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">描述</label>
        <div class="col-sm-10">
            <?php echo $form->textField($model,'description',array('size'=>60,'maxlength'=>255,'class'=>'form-control')); ?>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">分页</label>
        <div class="col-sm-10">
            <?php echo $form->textField($model,'page_size',array('size'=>60,'maxlength'=>255,'class'=>'form-control')); ?>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">分类模板</label>
        <div class="col-sm-10">
            <?php echo $form->textField($model,'template',array('size'=>60,'maxlength'=>255,'class'=>'form-control')); ?>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">文章模板</label>
        <div class="col-sm-10">
            <?php echo $form->textField($model,'article_template',array('size'=>60,'maxlength'=>255,'class'=>'form-control')); ?>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">备注</label>
        <div class="col-sm-10">
            <?php echo $form ->textField( $model , 'remark', array('class'=>'form-control'));?>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">是否显示</label>
        <div class="col-sm-10">
            <?php echo $form ->radioButtonList( $model , 'status' ,array('1'=>'是' , '0'=>'否' ), array('separator'=>'&nbsp;&nbsp;', 'class'=>''/*'template'=>'<span class="minimal-blue">{input} {label}</span>'*/));?>
        </div>
    </div>
    <div class="hr hr-18 dotted"></div>
    <div class="clearfix">
        <div class="col-md-offset-2 col-md-10">
            <button class="btn btn-sm btn-info" type="submit"><i class="ace-icon fa fa-check bigger-110"></i>提交</button>
            &nbsp; &nbsp; &nbsp;
            <button class="btn btn-sm" type="reset"><i class="ace-icon fa fa-undo bigger-110"></i>取消</button>
        </div>
    </div>
<?php $this->endWidget(); ?>